import {  DataTypes } from 'sequelize'
import { sequelize, syncDatabase } from './sequelize'
import { databaseConfig } from '../config'

const CustomColumnGroup = sequelize.define('CustomColumnGroup', {
  groupid: {
    type: DataTypes.INTEGER.UNSIGNED,
    primaryKey: true,
    autoIncrement: true,
    allowNull: false,
    comment: '自增id'
  },
  teamid: {
    type: DataTypes.INTEGER.UNSIGNED,
    allowNull: false,
    defaultValue: 0,
    comment: '团队id'
  },
  platform_type: {
    type: DataTypes.TINYINT.UNSIGNED,
    allowNull: false,
    defaultValue: 0,
    comment: '媒体平台类型'
  },
  project_type: {
    type: DataTypes.TINYINT.UNSIGNED,
    allowNull: false,
    defaultValue: 0,
    comment: '项目类型'
  },
  projectid: {
    type: DataTypes.INTEGER.UNSIGNED,
    allowNull: false,
    defaultValue: 0,
    comment: '项目id'
  },
  user_id: {
    type: DataTypes.INTEGER.UNSIGNED,
    allowNull: false,
    defaultValue: 0,
    comment: '用户id'
  },
  data_type: {
    type: DataTypes.TINYINT.UNSIGNED,
    allowNull: false,
    defaultValue: 0,
    comment: '数据类型'
  },
  group_name: {
    type: DataTypes.STRING(255),
    allowNull: false,
    defaultValue: '',
    comment: '分组名称'
  },
  group_type: {
    type: DataTypes.STRING(255),
    allowNull: false,
    defaultValue: '',
    comment: '分组类型'
  },
  group_data: {
    type: DataTypes.TEXT,
    allowNull: false,
    comment: '分组字段数据'
  },
  is_using: {
    type: DataTypes.TINYINT.UNSIGNED,
    allowNull: false,
    defaultValue: 0,
    comment: '是否正在使用'
  },
  create_time: {
    type: DataTypes.INTEGER.UNSIGNED,
    allowNull: false,
    defaultValue: 0,
    comment: '创建时间'
  },
  update_time: {
    type: DataTypes.INTEGER.UNSIGNED,
    allowNull: false,
    defaultValue: 0,
    comment: '更新时间'
  },
  creator: {
    type: DataTypes.INTEGER.UNSIGNED,
    allowNull: false,
    defaultValue: 0,
    comment: '创建用户id'
  },
  updator: {
    type: DataTypes.INTEGER.UNSIGNED,
    allowNull: false,
    defaultValue: 0,
    comment: '更新用户id'
  }
}, {
  tableName: databaseConfig.columnsTableName, // 指定表名
  timestamps: false, // 不需要 Sequelize 自动生成 createdAt 和 updatedAt 字段
});


syncDatabase();

export {
  CustomColumnGroup,
}